package org.jsola.hr.helper;

import org.jsola.hr.dto.VxCheckFaceAddDTO;
import org.jsola.hr.dto.VxCheckFaceUpdateDTO;
import org.jsola.hr.entity.VxCheckFaceDO;
import org.jsola.hr.query.VxCheckFaceQuery;
import org.jsola.hr.service.IVxCheckFaceService;
import org.jsola.hr.vo.VxCheckFaceVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 微信人脸核身
 *
 * @author zhr
 */
@Component
public class VxCheckFaceTestHelper extends BaseTestHelper {
    
    @Autowired
    private IVxCheckFaceService vxCheckFaceService;

    /**
     * 生成add测试数据
     * @return VxCheckFaceAddDTO
     */
    public VxCheckFaceAddDTO getVxCheckFaceAddDTO(){
        VxCheckFaceAddDTO vxCheckFaceAddDTO = new VxCheckFaceAddDTO();
        vxCheckFaceAddDTO.setUserId(getRandomValue("varchar",32));
        vxCheckFaceAddDTO.setOpenid(getRandomValue("varchar",64));
        vxCheckFaceAddDTO.setAppid(getRandomValue("varchar",32));
        vxCheckFaceAddDTO.setMchid(getRandomValue("varchar",32));
        vxCheckFaceAddDTO.setSubMchid(getRandomValue("varchar",32));
        vxCheckFaceAddDTO.setProjectName(getRandomValue("varchar",12));
        vxCheckFaceAddDTO.setEmployerName(getRandomValue("varchar",12));
        vxCheckFaceAddDTO.setUserName(getRandomValue("varchar",1024));
        vxCheckFaceAddDTO.setIdCardNumber(getRandomValue("varchar",1024));
        vxCheckFaceAddDTO.setEmploymentType(getRandomValue("varchar",32));
        vxCheckFaceAddDTO.setToken(getRandomValue("varchar",1024));
        vxCheckFaceAddDTO.setAuthenticateScene(getRandomValue("varchar",16));
        vxCheckFaceAddDTO.setAuthenticateSource(getRandomValue("varchar",64));
        vxCheckFaceAddDTO.setAuthenticateState(getRandomValue("varchar",32));
        vxCheckFaceAddDTO.setAuthenticateTime(getRandomValue("varchar",32));
        vxCheckFaceAddDTO.setAuthenticateFailedReason(getRandomValue("varchar",128));
        return vxCheckFaceAddDTO;
    }


    /**
     * 生成update测试数据
     * @return VxCheckFaceUpdateDTO
     */
    public VxCheckFaceUpdateDTO getVxCheckFaceUpdateDTO(VxCheckFaceVO vxCheckFaceVO){
        return vxCheckFaceService.selectDOById(vxCheckFaceVO.getId(), SITE_ID).to(VxCheckFaceUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return VxCheckFaceQuery
     */
    public VxCheckFaceQuery getVxCheckFaceQuery() {
        VxCheckFaceQuery vxCheckFaceQuery = new VxCheckFaceQuery();
        List<VxCheckFaceDO> vxCheckFaceDOList = vxCheckFaceService.list(new VxCheckFaceDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(vxCheckFaceDOList)) {
            VxCheckFaceDO vxCheckFaceDO = vxCheckFaceDOList.get(0);
            vxCheckFaceQuery = vxCheckFaceDO.to(VxCheckFaceQuery.class);
        }
        return vxCheckFaceQuery;
    }

    /**
     * 保存示例
     * @return VxCheckFaceVO
     */
    public VxCheckFaceVO saveVxCheckFaceExample(){
        VxCheckFaceAddDTO addDTO = this.getVxCheckFaceAddDTO();
        VxCheckFaceVO vxCheckFaceVO = vxCheckFaceService.save(addDTO,buildTokenUser());
        return vxCheckFaceVO;
    }


}

